package com.lagou.mr.task1;

import org.apache.hadoop.io.IntWritable;
import org.apache.hadoop.io.NullWritable;
import org.apache.hadoop.mapreduce.Reducer;

import java.io.IOException;

public class NumSortReducer extends Reducer<IntWritable, NullWritable,IntWritable,IntWritable> {

    int i = 0 ;
    IntWritable sortNum = new IntWritable();

    @Override
    protected void reduce(IntWritable key, Iterable<NullWritable> values, Context context) throws IOException,InterruptedException {

          //循环输出数据
          for(NullWritable value : values){
              sortNum.set(++i);
              context.write(sortNum,key);
          }
      }

}